package cn.com.gridinfo.sooc.utils;

import android.app.Activity;
import android.content.Intent;

import com.jeremy.arad.utils.AnimUtil;

import org.apache.http.message.BasicNameValuePair;

import cn.com.gridinfo.sooc.R;

/**
 * activity 跳转行为
 * @author jieli
 *
 */
public class IntentUtil {

	/**
	 * 默认启动  刷新当前Activity时使用
	 * @param activity
	 * @param cls
	 * @param name
	 */
	public static void default_start_activity(Activity activity, Class<?> cls, BasicNameValuePair...name){
		Intent intent=new Intent();
		intent.setClass(activity,cls);
		for(int i=0;i<name.length;i++)
		{
			intent.putExtra(name[i].getName(), name[i].getValue());
		}
		activity.startActivity(intent);
	}
	/**
	 * 默认启动  启动Activity时使用
	 * 滑动方向：右进左出
	 * @param activity
	 * @param cls
	 * @param name
	 */
	public static void intentSlidIn(Activity activity, Class<?> cls, int requestCode, BasicNameValuePair...name){
		Intent intent=new Intent();
		intent.setClass(activity,cls);
		for(int i=0;i<name.length;i++)
		{
			intent.putExtra(name[i].getName(), name[i].getValue());
		}
		activity.startActivityForResult(intent, requestCode);
		AnimUtil.intentSlidIn(activity);
	}
	/**
	 * 滑动方向：上进下出 模态页启动使用
	 * @param activity
	 * @param cls
	 * @param name
	 */
	public static void intentPushUp(Activity activity, Class<?> cls, int requestCode, BasicNameValuePair...name){
		Intent intent=new Intent();
		intent.setClass(activity,cls);
		for(int i=0;i<name.length;i++)
		{
			intent.putExtra(name[i].getName(), name[i].getValue());
		}
		activity.startActivityForResult(intent, requestCode);
		AnimUtil.intentPushUp(activity);
	}
}
